package indi.henry.demo.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import indi.henry.demo.model.Counter;
import indi.henry.demo.service.CounterService;
import lombok.RequiredArgsConstructor;

/**
 * Controller for the counter
 * 
 * @author Henry Hu
 */
@RequiredArgsConstructor
@RestController
@RequestMapping("/counter")
public class CounterController {

    private final CounterService counterService;

    /**
     * @return counting info for this app usage info
     */
    @GetMapping
    public Counter getCounter(@RequestParam String url) {
        return counterService.getCurrentByOrigin(url);
    }
}
